package WinterHomework.day01;

import java.util.Scanner;

//输入年月日，给出该天是该年的第多少天？
public class Demo02 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.println("请输入年月份。用空格分开:");
        int year = s.nextInt();
        int month = s.nextInt();
        int day = s.nextInt();
        isDays(year,month,day);
    }
    public static void isDays(int year, int month, int day) {
        int days = 0;
        switch (month) {
            //这里不加break；是为了让得到相应月份后，从当前月份一直加到一月
            //其中case对应的月份并不意味着要加对应月份，而是加前一月份，到1时加上’日‘就行
            case 12:
                days += 30;
            case 11:
                days += 31;
            case 10:
                days += 30;
            case 9:
                days += 31;
            case 8:
                days += 31;
            case 7:
                days += 30;
            case 6:
                days += 31;
            case 5:
                days += 30;
            case 4:
                days += 31;
            case 3:
                if (year % 4 == 0 && year % 100 == 0) {
                    days += 29;
                } else {
                    days += 28;
                }
            case 2:
                days += 31;
            case 1:
                days += day;
        }
        System.out.println("这是"+year+"年，第"+days+"天。");
    }
}
